package com.javajavadog.ui;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.javajavadog.ui.base.FragmentHostActivity;

public class TabsActivity extends FragmentHostActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public String getTitleText() {
        return "Basic Controls";
    }

    @Override
    public Fragment getContentFragment() {
        return ControlsBasicFragment.newInstance();
    }

    @Override
    public boolean enableBackButton() {
        return true;
    }

    public static class ControlsBasicFragment extends Fragment {

        public static ControlsBasicFragment newInstance() {
            ControlsBasicFragment f = new ControlsBasicFragment();
            return f;
        }

        public ControlsBasicFragment() {
            // empty
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            return inflater.inflate(R.layout.fragment_ui_controls, null);
        }

        @Override
        public void onViewCreated(View view, Bundle savedInstanceState) {
            super.onViewCreated(view, savedInstanceState);

            Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
            // Create an ArrayAdapter using the string array and a default spinner layout
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(),
                    R.array.planets_array, android.R.layout.simple_spinner_item);
            // Specify the layout to use when the list of choices appears
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            // Apply the adapter to the spinner
            spinner.setAdapter(adapter);
        }
    }
}
